import java.net.*;
import java.io.*;

public class LocalTalk1 {

    public static void main(String args[] ) {
     try {
	Socket sk = new Socket("sleipnir.cs.csubak.edu", 8921);
	InputStream instr = sk.getInputStream();
	OutputStream outstr = sk.getOutputStream();
	ObjectInputStream in = new ObjectInputStream ( instr );
	ObjectOutputStream out = new ObjectOutputStream(outstr);
	out.flush();

	String message;
	int mnum = 1;

	while ( true ) {
		message = "Client message: " + mnum++;
		System.out.println("In cline while loop");
		out.writeObject ( message ); 
		out.flush();
		/*
		if ( in.available() > 0 ) {
			message = (String) in.readObject();
			System.out.println( message );
		}
		*/

		Thread.sleep((int) ( Math.random() * 5000) +1000 );
	}
     } catch ( Exception e ) { e.printStackTrace(); }
   }
}
